package com.commonlyUsedClass.Date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/***
 * @ClassName: SimpleDate
 * @Description:
 * @Auther: 送一一块二向箔
 * @Date: 11:05 2022/2/15
 * @version : V1.0
 */
public class SimpleDate {
    public static void main(String[] args) {

        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH-mm-ss");
        String format = simpleDateFormat.format(date);
        System.out.println(format);

        //可以先通过getTime得到Date格式，然后再进行格式化
        Calendar calendar = Calendar.getInstance();
        System.out.println(calendar);
        String format1 = simpleDateFormat.format(calendar.getTime());
        System.out.println(format1);

        try {
            Date parse = simpleDateFormat.parse("2002/02/15 11-35-03");
            System.out.println(parse.toString());

        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
